Page({
  data: {
    name: '',
    age: '',
    genders: ['男', '女'],
    selectedGender: '',
    phone: '',
    introduction: ''
  },
  handleInput(e) {
    const field = e.currentTarget.dataset.field;
    const value = e.detail.value;
    this.setData({
      [field]: value
    });
  },
  handlePickerChange(e) {
    const field = e.currentTarget.dataset.field;
    const index = e.detail.value;
    const selectedValue = this.data.genders[index];
    this.setData({
      [field]: selectedValue
    });
  },
  submitForm() {
    const { name, age, selectedGender, phone, introduction } = this.data;
    if (!name || !age || !selectedGender || !phone) {
      wx.showToast({
        title: '请填写必填信息',
        icon: 'none'
      });
      return;
    }
    // 这里可以添加提交表单到服务器的逻辑
    console.log('报名信息:', {
      name,
      age,
      gender: selectedGender,
      phone,
      introduction
    });
    wx.showToast({
      title: '报名成功',
      icon: 'success'
    });
    // 清空表单
    this.setData({
      name: '',
      age: '',
      selectedGender: '',
      phone: '',
      introduction: ''
    });
  }
})